<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <input type="text">
<script>
    const input=document.querySelector('input')
    input.addEventListener('keyup',function (e){
        console.log(e.key)
        if (e.key==='Enter'){
            console.log('我打了回车')
        }
    })
</script>
</body>
</html>